function onPageReady() {
    try {
        $('.search-bar').css('padding-top', plus.navigator.getStatusbarHeight() * 2 + 'px');
    } catch (e) {
    }
    $(".title span").html("看&nbsp;时&nbsp;势");
    var result;
    window.onRefresh = function () {
        if (!result) return;
    };
    ajax({
        url: "/api/home/getHomePageInfo",
        type: "get",
        dataType: "json",
        headers: {},
        success: function (r) {
            result = r;
            $('.scroll-container').render('#banner', {}, 'before');
            for (var i in result.data.homeNews) {
                $(".banList").render("#banList", result.data.homeNews[i]);
                $(".fomW>div").render("#fomW", result.data.homeNews[i]);
            }
            $(".banner").swBanner();
            initPreview('.banner-img', true);
            onRefresh();
        }
    });
    var page = initPage(".scroll-container", ".scroll-item", ".list", {
        url: "/api/home/getEventList",
        type: "get",
        dataType: "json",
        headers: {},
        data: new Page({orderType: "DESC"}),
        success: function (result) {
            for (var i in result.data) {
                var item = new EventBean(result.data[i]);
                item.title = item.title.replace(new RegExp($('.search-input').val(), 'g'), '<span>' + $('.search-input').val() + '</span>');
                $(".list").render("#item", item, "append");
                page.setLastRecordId(item.id);
            }
        }
    });

    function onSearch() {
        page.refresh({keyWords: $('.search-input').val()});
    }

    $('.search-btn').on('click', function () {
        onSearch();
    });
    $('.clean-btn').on('click', function () {
        var $this = $(this);
        $this.removeClass('js_show');
        $this.parent().find('input').val('').focus();
        onSearch();
    });
    $(document).keydown(function (event) {
        if (event.keyCode === 13) {
            onSearch()
        }
    });
    $(document).on('click', function (event) {
        var $target = $(event.target);
        $('.clean.js_show').removeClass('js_show');
        if ($target.is('.clean-btn') && $target.parent().is('.input-cleanable')) {
            $target.parent().find('input').val('').focus();
            onSearch();
            $target.removeClass('js_show');
        } else if ($target.parent().is('.input-cleanable')) {
            if ($target.parent().find('input').val()) {
                $target.parent().find('.clean-btn').addClass('js_show');
            } else {
                $target.parent().find('.clean-btn').removeClass('js_show');
            }
        }
    });
    $(document).on('input', '.input-cleanable input', function () {
        var $this = $(this);
        if ($this.val()) {
            $this.parent().find('.clean-btn').addClass('js_show');
        } else {
            $this.parent().find('.clean-btn').removeClass('js_show');
        }
    });
}